package com.sxf.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.sxf.dao.TermDAO;
import com.sxf.domain.blog.Term;
import com.sxf.domain.viewbean.TermVO;
import com.sxf.mybatis.page.Pagination;
import com.sxf.querybean.TermQuery;
@Repository
public class TermDAOImpl extends SuperDAOImpl implements TermDAO {

	private static final String STATEMENT_QUERY = "mybatis.xml.Term.query";

	@Override
	public Pagination<TermVO> queryPage(TermQuery query) {
		return queryPageTemplate(STATEMENT_QUERY, query);
	}

	@Override
	public TermVO queryOne(TermQuery query) {
		List<TermVO> termList = queryListTemplate(STATEMENT_QUERY, query);
		if (termList != null && !termList.isEmpty()) {
			return termList.get(0);
		}
		return null;
	}

	@Override
	public List<TermVO> queryList(TermQuery query) {
		return queryListTemplate(STATEMENT_QUERY, query);
	}

	@Override
	public long queryNumber(TermQuery query) {
		return queryNumberTemplate(STATEMENT_QUERY, query);
	}

	@Override
	public int insert(Term info) {
		if (info != null) {
			int i = st.insert("mybatis.xml.Term.insertSelective", info);
			return i;
		}
		return 0;
	}

	@Override
	public int update(Term info) {
		if (info != null) {
			return st.update("mybatis.xml.Term.updateByPrimaryKeySelective",
					info);
		}
		return 0;
	}

	@Override
	public int delete(Term info) {
		if (info != null) {
			return st.delete("mybatis.xml.Term.deleteByPrimaryKey", info);
		}
		return 0;
	}

}
